/*
 * @Author: Kiro AI Assistant
 * @Date: 2025-01-10
 * @Description: 音频播放相关异常类
 */

/// 音频异常基类
abstract class AudioException implements Exception {
  final String message;
  final String? code;
  final Object? originalError;

  const AudioException(this.message, {this.code, this.originalError});

  @override
  String toString() =>
      'AudioException: $message${code != null ? ' (code: $code)' : ''}';
}

/// 音频播放异常
class AudioPlayException extends AudioException {
  const AudioPlayException(
    super.message, {
    super.code,
    super.originalError,
  });

  @override
  String toString() =>
      'AudioPlayException: $message${code != null ? ' (code: $code)' : ''}';
}

/// 音频加载异常
class AudioLoadException extends AudioException {
  const AudioLoadException(
    super.message, {
    super.code,
    super.originalError,
  });

  @override
  String toString() =>
      'AudioLoadException: $message${code != null ? ' (code: $code)' : ''}';
}

/// 音频网络异常
class AudioNetworkException extends AudioException {
  final int? statusCode;

  const AudioNetworkException(
    super.message, {
    super.code,
    this.statusCode,
    super.originalError,
  });

  @override
  String toString() =>
      'AudioNetworkException: $message${statusCode != null ? ' (status: $statusCode)' : ''}${code != null ? ' (code: $code)' : ''}';
}

/// 音频权限异常
class AudioPermissionException extends AudioException {
  const AudioPermissionException(
    super.message, {
    super.code,
    super.originalError,
  });

  @override
  String toString() =>
      'AudioPermissionException: $message${code != null ? ' (code: $code)' : ''}';
}

/// 音频格式异常
class AudioFormatException extends AudioException {
  final String? format;

  const AudioFormatException(
    super.message, {
    super.code,
    this.format,
    super.originalError,
  });

  @override
  String toString() =>
      'AudioFormatException: $message${format != null ? ' (format: $format)' : ''}${code != null ? ' (code: $code)' : ''}';
}
